import React,{useState,useEffect} from 'react'
import { Drawer,Empty } from 'antd';

let timer:any = null
const History = (props:any) =>{

    const [list,setList] = useState([])

    useEffect(()=>{
        let logInfo = localStorage.getItem('log');
        let list = logInfo?JSON.parse(logInfo):[]
        setList(list)
        timer = setInterval(()=>{
            console.log('timer')
        })
        return ()=>{
            console.log('销毁')
            timer && clearInterval(timer)
        }
    },[])

    return (
        <>
            <Drawer title="历史信息" width={560} placement="right" open={true} onClose={props.close}>
                {
                    list.length?list.map((item,index)=>{
                        return <p key={index}>{item}</p>
                    }):<Empty description="暂无日志信息"/>
                }
            </Drawer>
        </>
    )
}

export default History